package pers.vic.grow.netty.chapter_1_00.aio.client;

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.nio.charset.Charset;
import java.util.concurrent.Future;

/**
 * @description: AIO客户端
 * @author Vic.xu
 * @date: 2021/9/1 0001 17:39
 */
public class AioClient {


    public static void main(String[] args) throws Exception, InterruptedException {
        AsynchronousSocketChannel socketChannel = AsynchronousSocketChannel.open();
        Future<Void> connect = socketChannel.connect(new InetSocketAddress("127.0.0.1", 12001));
        connect.get();
        socketChannel.read(ByteBuffer.allocate(1024), null, new AioClientHandler(socketChannel, Charset.forName("GBK")));
        Thread.sleep(100000);
    }
}

